***********************************************************
***************REPLICATION CODE FOR TABLES*****************
*************HIGH PROFILE CRIMINAL VIOLENCE"***************
***********************************************************

use "Dataset_HighProfileCriminalViolence.dta", clear
*Note: See Codebook_HighProfileCriminalViolence.doc for variable coding and description

*************
***TABLE 1***
*************
tab juxtaposition


*************
***TABLE 2***
*************
/*MODEL 1. TURF WARS USING CVM DATA */
#delimit ;
xtnbreg aggr_sum cvmr1000 perc_tax mpoff1000 alternancia_mun alternancia_st  enp_mun enp_st 
center northcenter north gulf pacific southeast, i( cve_inegi) re ;
#delimit cr
outreg2 using capam_tab3,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 1)  replace 
estat ic

#delimit ;
xtnbreg aggr_sum cvmr1000 perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st 
 center northcenter north gulf pacific southeast, i( cve_inegi) re irr;
#delimit cr


/*MODEL 2. TURF WARS USING GOVERNMENT DATA */
#delimit ;
xtnbreg aggr_sum menfeje1000 perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st 
 center northcenter north gulf pacific southeast, i( cve_inegi) re;
#delimit cr
outreg2 using capam_tab3,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 2)  append
estat ic

#delimit ;
xtnbreg aggr_sum menfeje1000 perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st 
 center northcenter north gulf pacific southeast, i( cve_inegi) re irr;
#delimit cr


*************
***TABLE 3***
*************

/*MODEL 1. GOVERNANCE OPPORTUNITIES, USING JUXTAPOSITION DUMMIES*/
#delimit ;
xtnbreg aggr_sum cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9 elect_local elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific  southeast, i( cve_inegi) re ;
#delimit cr
outreg2 using capam_tab4,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 1) replace 
estat ic


#delimit ;
xtnbreg aggr_sum cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9 elect_local elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific  southeast, i( cve_inegi) re irr ;
#delimit cr

/*MODEL 2. GOVERNANCE OPPORTUNITIES, USING JUXTAPOSITION INDEX */
*gen juxtaposition=0 if juxt1==1
*replace juxtaposition=1 if juxt2==1
*replace juxtaposition=2 if juxt3==1
*replace juxtaposition=3 if juxt4==1
*replace juxtaposition=4 if juxt5==1
*replace juxtaposition=5 if juxt6==1
*replace juxtaposition=6 if juxt7==1
*replace juxtaposition=7 if juxt8==1
*replace juxtaposition=8 if juxt9==1

#delimit ;
xtnbreg aggr_sum cvmr1000 juxtaposition elect_local elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific  southeast, i( cve_inegi) re ;
#delimit cr
outreg2 using capam_tab4,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 2) append 
estat ic

#delimit ;
xtnbreg aggr_sum cvmr1000 juxtaposition elect_local elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific  southeast, i( cve_inegi) re irr ;
#delimit cr

*************
***TABLE 4***
*************

/*MODEL 1. TURF WARS * JUSTAPOSITION */
*gen juxt_cvm=juxtaposition*cvmr1000

#delimit ;
xtnbreg aggr_sum cvmr1000 juxtaposition juxt_cvm
 elect_local elect_fed lag_neightotal perc_tax mpoff1000
alternancia_mun alternancia_st enp_mun enp_st center northcenter 
north gulf pacific southeast, 
i( cve_inegi) re ;
#delimit cr
estat ic    
outreg2 using capam_tab5,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 1)  replace

#delimit ;
xtnbreg aggr_sum cvmr1000 juxtaposition juxt_cvm
 elect_local elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific southeast, 
i( cve_inegi) re irr ;
#delimit cr

/*MODEL 2. TURF WARS * LOCAL ELECTION CYCLE */
*gen elec_cvm=elect_local*cvmr1000

#delimit ;
xtnbreg aggr_sum cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9
elect_local elec_cvm elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific southeast, 
i( cve_inegi) re ;
#delimit cr
outreg2 using capam_tab5,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 2)  append
estat ic

#delimit ;
xtnbreg aggr_sum cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9 
elect_local elec_cvm elect_fed lag_neightotal
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st
 center northcenter north gulf pacific southeast, 
i( cve_inegi) re irr ;
#delimit cr

***********************
***APPENDIX, TABLE A.II
***********************
*gen aggr_dummy=1 if aggr_sum>0
*replace aggr_dummy=0 if aggr_sum==0

/*MODEL 1. LOGIT MODEL WITH BINARY DV */
#delimit ;
xtlogit aggr_dummy cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9 elect_local elect_fed lag_neightotal 
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st  
center northcenter north gulf pacific southwest, i( cve_inegi) re ;
#delimit cr
outreg2 using capam_app3,  bracket(se) dec(3) addstat(Log-likelihood, e(ll), N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 1)  replace

/*MODEL 2. RARE LOGIT MODEL WITH BINARY DV*/
*Install relogit through https://gking.harvard.edu/scholar_software/relogit-rare-events-logistic-regression/1-1-stata
#delimit ;
relogit aggr_dummy cvmr1000 juxt2 juxt3 juxt4 juxt5 juxt6 
juxt7 juxt8 juxt9 elect_local elect_fed lag_neightotal 
perc_tax mpoff1000 alternancia_mun alternancia_st enp_mun enp_st  
center northcenter north gulf pacific southwest, cluster(cve_inegi) ;
#delimit cr

outreg2 using capam_app3,  bracket(se) dec(3) addstat(N, e(N)) alpha( .01, .05, .10) symbol(***, **, *) cttop(Model 2)  append


